﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace V5_EaspLibs.Utility {
    public class RSS {
        public string LoadRSS(string RssUrl, string nodename) {
            XmlDocument doc = new XmlDocument();
            string Rss = "";
            if (RssUrl != "") {
                try {
                    doc.Load(RssUrl);
                    XmlNodeList nodelist = doc.GetElementsByTagName("item");
                    XmlNodeList objItems1;
                    if (doc.HasChildNodes) {
                        foreach (XmlNode node in nodelist) {
                            if (node.HasChildNodes) {
                                objItems1 = node.ChildNodes;
                                foreach (XmlNode node1 in objItems1) {
                                    if (nodename.ToLower() == node1.Name) {
                                        return node1.InnerText;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception) {
                    Rss = "RSS Feed 源数据出错！";
                }
            }
            else {
                Rss = "未找到信息源，您可刷新重试或联系管理员！";
            }
            return Rss;
        }

    }
}
